package org.jeecg.modules.basic.demo.bed.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.basic.demo.apartment.entity.LwgyBaseApartment;
import org.jeecg.modules.basic.demo.bed.entity.*;
import org.jeecg.modules.basic.demo.school.entity.LwgyBaseSchool;
import org.jeecg.modules.basic.demo.student.entity.LwgyBaseStudent;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * @Description: 床位信息
 * @Author: jeecg-boot
 * @Date:   2021-01-20
 * @Version: V1.0
 */

public interface LwgyBaseBedMapper extends BaseMapper<LwgyBaseBed> {

    List<LwgyBaseBed> queryPageListCustom(Page<LwgyBaseBed> page, @Param(Constants.WRAPPER)QueryWrapper<LwgyBaseBed> queryWrapper);

    List<LwgyBaseBed> queryPageListHotelInfo(Page<LwgyBaseBed> page, @Param(Constants.WRAPPER)QueryWrapper<LwgyBaseBed> queryWrapper);

    List<LwgyBaseBed> queryPageListAllBed(Page<LwgyBaseBed> page, @Param(Constants.WRAPPER)QueryWrapper<LwgyBaseBed> queryWrapper);

    List<LwgyBaseBed> queryPageListCustomScore(Page<LwgyBaseBed> page,@Param("scaleBatches") String scaleBatches,@Param(Constants.WRAPPER)QueryWrapper<LwgyBaseBed> queryWrapper);

    @MapKey("pid")
    List<Map<String, String>> queryListByPid(@Param("pid")String pid);

    List<LwgyBedAssignment> queryPageNullBed(Page<LwgyBedAssignment> page, @Param(Constants.WRAPPER)QueryWrapper<LwgyBedAssignment> queryWrapper);

    @MapKey("pid")
    List<Map<String, String>> queryListByPidAndWork(@Param("pid")String pid,@Param("workNo")String workNo,@Param("apartmentType")String apartmentType);

    @Select("SELECT role_code FROM sys_role WHERE id IN (SELECT role_id FROM sys_user_role WHERE user_id = #{id})")
    List<String> getRoleById(@Param("id")String id);

    IPage<LwgyBaseBed> queryPageFacultyBeds(@Param("page") Page<LwgyBaseBed> page, @Param("lwscl") LwgyBaseSchool lwgyBaseSchool);

    List<LwgyBaseStudent> queryBedByScInfoId(LwgyBaseApartment lwgyBaseApartment, String studentSex);

    LwgyBaseBed queryBedById(String id);

    LwgyBaseBed queryBedByStuId(String studentId);

    List<LwgyBaseBed> getBedIdList(String apartmentId, String apartmentType);

    List<LwgyBaseBed> getBedListByStuId(String[] studentId);

    List<LwgyBaseBed> getBedListByStuId2(String[] studentId);

    LwgyBaseStudent getStuInfoByBedId(String bedId);

    List<LwgyBaseStudent> getStuInfoByRoomId(String roomId);

    void deleteBatchPIds(List<String> asList);

    String get_maxInnerCode(String pid);

    String getMaxBedName(String pid);


    List<ImportLwgyBedsA> outBedXls(@Param("lwgyBed")LwgyBaseApartment lwgyBed);

    List<LwgyBaseBed> queryHolidayPageListCustom(Page<LwgyBaseBed> page,  @Param(Constants.WRAPPER)QueryWrapper<LwgyBaseBed> queryWrapper);


    List<LwgyBaseBed> getStuBed();

    void updateStu(String admin_id, List<String> lists);

//    void updatePrice(BedAndApart bedAndApart);

    @Select("select * from v_lwgy_base_beds AS vb where student_id is not null and student_id !='null' and student_id !=''")
    List<LwgyBaseBed> queryBedList();

    Integer updateStatusTo1(@Param("lists")List<String> lists);

    Integer updateStatusTo0(@Param("lists")List<String> lists);

    LwgyBaseBed getBedByStuId(@RequestParam(name = "studentId") String studentId);

    List<LwgyBaseBed> findChangeRoom();

    List<BedAndApart> getAllBeds(@Param(Constants.WRAPPER)QueryWrapper<BedAndApart> queryWrapper);

    List<LwgyBaseSchool> getYear();

    List<LwgyBaseBed> getHotelData(@Param(Constants.WRAPPER)QueryWrapper<LwgyBaseBed> queryWrapper);

    void updateBatchByBedId(List<LwgyBaseBed> bedList);

    @Select("select a.campus_name,a.building_name,a.unit_name,a.layer_name,a.room_name,a.room_id,t.students  from" +
            "(select room_id ,GROUP_CONCAT(student_id)as students from lwgy_base_bed where student_id is not null and student_id!= '' and del_flag=0 group by room_id)t left JOIN " +
            "v_lwgy_base_room a on t.room_id = a.room_id")
    List<Map<String,String>> queryRoomInfo();


}
